package rs.dalao.syc.user.all.dao.persist.repository.impl;/*
 *   @author:Casin
 *   @date:2023/8/13
 *   @code:
 */

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import rs.dalao.syc.common.pojo.vo.PageData;
import rs.dalao.syc.common.util.PageInfoToPageDataConverter;
import rs.dalao.syc.user.all.dao.persist.mapper.MedicineMapper;
import rs.dalao.syc.user.all.dao.persist.repository.IMedicineRepository;
import rs.dalao.syc.user.all.pojo.vo.MedicineOrderVO;

import java.util.List;

@Repository
@Slf4j
public class MedicineRepositoryIml implements IMedicineRepository {
    @Autowired
    private MedicineMapper mapper;
    @Override
    public PageData<MedicineOrderVO> getMedicineOrderByUserId(Long userId,Integer pageNum,Integer pageSize) {
        log.debug("开始执行【查询用户列表】的数据访问，页码：{}，每页记录数：{}", pageNum, pageSize);
        PageHelper.startPage(pageNum, pageSize);
        List<MedicineOrderVO> list = mapper.getMedicineOrderByUserId(userId);
        PageInfo<MedicineOrderVO> pageInfo = new PageInfo<>(list);
        return PageInfoToPageDataConverter.convert(pageInfo);
    }
}
